<?php
	//views/groups/index.ctp
?>
<h2>Group</h2>

<div>
	<div id="col-right" class="span-13">
		<div class="col-wrap">
			<?php echo$form->create('Search', array('url' => '/groups/dataSearch'))?>
			<p class="search-box" style="margin: 0px;">
				<label class="hidden" for="post-search-input">Search Name:</label> 	
				<?php echo$form->input('Search.name', array('class' => 'search-input', 'id' => 'name-search-input', 'label' => '', 'div' => false))?>
				<?php echo$form->submit('Search Name', array('class' => 'button', 'div' => false))?>
			</p>
								
			<input name="mode" value="list" type="hidden">
			<div class="tablenav">	
				<div class="tablenav-pages">
					<span class="displaying-num">
						<?php echo $paginator->counter(array( 'format' => 'Display %start%-%end% of %count%')); ?>
					</span>
					<?php
						echo $paginator->options(array('url' => $this->passedArgs));
						echo $paginator->prev('« ', array('class' => 'prev page-numbers'));
						echo ' '.$paginator->numbers(array('class' => 'page-numbers', 'separator' => ' ', 'modulus' => '5')).' ';
						echo $paginator->next(' »', array('class' => 'next page-numbers'));
					?>
				</div>
			</div>
			<?php echo$form->end()?>
								
			<?php echo$form->create('Delete', array('url' => '/groups/multiDelete'))?>
			<table class="widefat post fixed" cellspacing="0">
				<thead>
					<tr>
						<th scope="col" id="cb" class="manage-column column-cb check-column" style="width:15px;"><input type="checkbox"></th>
						<th scope="col" id="group-name" class="manage-column column-title"><?php echo$paginator->sort('Tên group', 'name')?></th>
						<th scope="col" id="user-last-visit" class="manage-column column-date" style="width: 16%"><?php echo$paginator->sort('Ngày tạo', 'created')?></th>
					</tr>
				</thead>				
				<tfoot>
					<tr>
						<th scope="col" class="manage-column column-cb check-column" style=""><input type="checkbox"></th>
						<th scope="col" class="manage-column column-title" style=""><?php echo$paginator->sort('Tên group', 'name')?></th>
						<th scope="col" class="manage-column column-date" style=""><?php echo$paginator->sort('Ngày tạo', 'created')?></th>
					</tr>
				</tfoot>
				<tbody>
				<?php 
				//Set param for url
				$url = $this->passedArgs;
				$url['action'] = 'index';
				
				foreach ($groups as $group)
				{
				?>
					<tr id="post-<?php echo$group['Group']['id']?>" class="alternate author-other status-publish iedit" valign="top">
						<th scope="row" class="check-column">
							<?php echo$form->input("record.".$group['Group']['id'], array('label' => '','type' => 'checkbox'))?>
						</th>
						<td class="post-title column-title">
							<strong><a class="row-title" href="#" title="Edit &quot;<?php echo$group['Group']['name']?>"><?php echo$group['Group']['name']?></a></strong>
							<div class="row-actions">
								<span class="edit">
								<?php 
								//Set param for url
								$url['Category.cat_id'] = $group['Group']['id'];
								?>
								<a href="<?php echo$paginator->url($url)?>" title="Edit">Edit</a> | </span>
								<span class="delete"><a class="submitdelete" title="Delete" href="<?php echo$html->url('/groups/delete/'.$group['Group']['id'])?>" onclick="if ( confirm('You are about to delete \'<?php echo$group['Group']['name']?>\'\n \'Cancel\' to stop, \'OK\' to delete.') ) { return true;}return false;">Delete</a></span>
							</div>
						</td>
											
						<td class="date column-date">
							<abbr title="<?php echo$time->format('Y/m/d h:m:s', $group['Group']['created'])?>"><?php echo$time->format('Y/m/d', $group['Group']['created'])?></abbr>
						</td>
					</tr>
				<?php 
				}
				?>
										
				</tbody>
			</table>
			<!-- bof tablenav -->
			<div class="tablenav">
				<div class="tablenav-pages">
					<span class="displaying-num"><?php echo $paginator->counter(array( 'format' => 'Display %start%-%end% of %count%')); ?></span>
					<?php
						echo $paginator->prev('«', array('class' => 'prev page-numbers'));
						echo ' '.$paginator->numbers(array('class' => 'page-numbers', 'separator' => ' ', 'modulus' => '5')).' ';
						echo $paginator->next('»', array('class' => 'next page-numbers'));
					?>
				</div>
				<div class="alignleft actions">
					<!-- 
					<select name="action2">
						<option value="-1" selected="selected">Bulk Actions</option>
						<option value="edit">Edit</option>
						<option value="delete">Delete</option>
					</select>
					 -->
					<?php echo$form->submit('Delete', array('name' => 'doaction2', 'class' => 'button-secondary action', 'div' => false))?> 
					<br class="clear">
				</div>
			</div><!-- eof tablenav -->
			<?php echo$form->end()?>
		</div>
	</div><!-- eof div#col-right -->						
	<!-- bof div#col-left -->
	<div id="col-left" class="span-10 last">
		<div class="col-wrap">
			<div class="form-wrap">
				<h3>Thông tin Group</h3>
				<?php echo$form->create('Group', array('url' => $paginator->url($url, true), 'class' => 'add:the-list: vaidate'))?>
					<?php echo$form->hidden('id')?>
					<div class="form-field form-required">
						<label for="cat_name">Tên Group</label>
						<?php
							echo $form->input('Group.name', array('label' => false, 'size' => 40, 'aria-required' => true, 'id' => 'cat_name', 'div' => false, 'error' => false));
							echo $form->error('Group.name') == true ? "<p>{$form->error('Group.name')}</p>" : "<p>Form này dùng để thêm group, khi bạn chọn sửa group thì form sẽ trở thành trạng thái sửa, sau khi sửa xong form sẽ tự động trở về trạng thái thêm mới.</p>";
						?>
					</div>
					
					<p class="submit"><?php echo$form->submit('Apply', array('class' => 'button', 'div' => false));?></p>
				<?php echo$form->end();?>
			</div>
		</div>
	</div>					
</div>